package org.cyz.tools.core.assembly;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import org.cyz.tools.common.util.ImageUtil;

/**
 * @author abccy
 * @title: SystemMenu
 * @projectName RedisGUI
 * @description: 右键菜单
 * @date 2020-8-1821:11
 */
public class RightClickMenu extends ContextMenu {

    private ImageUtil imageUtil=new ImageUtil();
    private static RightClickMenu rightClickMenu=null;
    /**
     * 私有构造函数
     */
    private RightClickMenu(){
        MenuItem addMenuItem = new MenuItem("新增",imageUtil.getIcon("add"));
        MenuItem delMenuItem = new MenuItem("删除",imageUtil.getIcon("delete"));
        MenuItem editMenuItem = new MenuItem("修改",imageUtil.getIcon("edit"));

        getItems().add(addMenuItem);
        getItems().add(delMenuItem);
        getItems().add(editMenuItem);
        /*事件监听*/
        addMenuItem.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent actionEvent) {
                //新增操作

            }
        });
        delMenuItem.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent actionEvent) {
                //删除操作

            }
        });

    }


    /**
     * 获取实例
     */
    public static RightClickMenu getInstance()
    {
        if (rightClickMenu == null)
        {
            rightClickMenu = new RightClickMenu();
        }
        return rightClickMenu;
    }

}
